package com.jyw.business.de.domain.dto.web;

import com.jyw.business.de.constant.TaskStateConstant;
import com.jyw.business.de.domain.DeTaskInfo;
import com.jyw.common.utils.DateUtils;
import com.jyw.system.domain.vo.SimpleFileVo;
import com.jyw.system.utils.FileUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.List;

@Data
@ApiModel("任务处理请求实体")
public class TaskMakeDto {

    @ApiModelProperty("任务id")
    @NotNull(message = "任务id不能为空")
    private Long id;

    @ApiModelProperty("处理描述")
    private String remarks;

    @ApiModelProperty("处理附件")
    private List<SimpleFileVo> taskEnclosure;

    public DeTaskInfo buildTask(){
        DeTaskInfo taskInfo = new DeTaskInfo();
        taskInfo.setTaskState(TaskStateConstant.COMPLETED);
        taskInfo.setTaskEnclosure(FileUtils.fileToId(getTaskEnclosure()));
        taskInfo.setUpdateTime(DateUtils.getNowDate());
        return taskInfo;
    }
}
